package com.leyu.mall.admin.goods.service.impl;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.leyu.mall.admin.goods.dao.GoodsCategoryMapper;
import com.leyu.mall.admin.goods.domain.GoodsCategory;
import com.leyu.mall.admin.goods.service.IGoodsCategoryService;
import com.leyu.mall.common.facade.IGoodsCategoryFacade;

@Service
@Transactional(rollbackFor = Exception.class)
public class GoodsCategoryServiceImpl implements IGoodsCategoryService,IGoodsCategoryFacade {

	@Resource(name = "goodsCategoryMapper")
	private GoodsCategoryMapper goodsCategoryMapper;

	public GoodsCategory getGoodsCategoryById(Long entity_id) throws Exception {
		return goodsCategoryMapper.getGoodsCategoryById(entity_id);
	}

	public void save(GoodsCategory entity) throws Exception {
		if (entity.getCategoryID() == null) {
			goodsCategoryMapper.addGoodsCategory(entity);

		} else {

			goodsCategoryMapper.updateGoodsCategory(entity);
		}
	}
	public void deleteGoodsCategory(Long id) throws Exception {
		goodsCategoryMapper.deleteGoodsCategory(id);
	}
	public List<GoodsCategory> getAllGoodsCategory() throws Exception {
		return goodsCategoryMapper.getAllGoodsCategory();

	}
	
	public  List<GoodsCategory> getAllCategoryLevel() throws Exception {
		return goodsCategoryMapper.getAllCategoryLevel();
	}
	public  List<GoodsCategory> getAllDisplayCategoryList() throws Exception{
		return goodsCategoryMapper.getAllDisplayCategoryList();
	}
}